
//https://leetcode.cn/problems/rotate-image/description/?envType=study-plan-v2&envId=top-100-liked
//旋转图像

class Solution {
public:
    void rotate(vector<vector<int>>& matrix) 
    {
        int n = matrix.size();

        //先水平反转,奇数可以少转
        for(int i = 0; i < n / 2; i++)
        {
            for(int j = 0; j < n; j++)
            {
                swap(matrix[i][j],matrix[n - i - 1][j]);
            }
        }    

        //对角线翻转, 对角线上的可以不转
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < i; j++)
            {
                swap(matrix[i][j],matrix[j][i]);
            }
        }
    }
};